# coding: utf-8

from web import form

vlen = form.regexp(r".{3,32}$", 'must be between 3 and 20 characters')
vemail = form.regexp(r".*@.*", "must be a valid email address")

login_form = form.Form(
    form.Textbox("username", vemail, description="登录邮箱", size="16", maxlength="32"),
    form.Password("password", vlen, description="密  码", size="16", maxlength="32"),
    form.Button("submit", type="submit", description="登录")
)

registe_form = form.Form(
    form.Textbox("username", vemail, description="登录邮箱", size="16", maxlength="32"),
    form.Password("password", vlen, description="密码", size="16", maxlength="32"),
    form.Password("rpassword", vlen, description="再次输入密码", size="16", maxlength="32"),
    form.Button("submit", type="submit", description="登录"),
    validators = [form.Validator("2次输入密码不一致", lambda i: i.password == i.rpassword)]
)

